<template>
	<view class="main">
		<header-vue :back="true">
			<template v-slot:btnLt>
				<view class="flex search-box">
					<i class="iconfont icon-search font40"></i>
					<input v-model="params.keyword" placeholder="请输入关键词" class="input" @input="searchInput" />
				</view>
			</template>
		</header-vue>
		<scroll-view class="scroll-x white-box" :scroll-x="true">
			<view class="flex start" style="height: 100%;">
				<view v-for="(item, index) in typeList" class="font28 item" :class="{'fontbold-500': type === index}" @click="type = index">{{item.name}}（430）
				</view>
			</view>
		</scroll-view>
		<scroll-view class="list" :scroll-y="true">
			<view v-for="item in 10" :key="item" class="white-box">
				<view class="flex user-info">
					<image :src="IMAGE_URL + '/static/login/bg.png'" class="avatar"></image>
					<view style="width: 100%;">
						<view class="flex between user-name">
							<view class="font32 fontbold-500">LR-M</view>
							<view class="time font24">今天 09:21</view>
						</view>
						<view class="flex start star">
							<view v-for="starIndex in 5" class="iconfont icon-starFull font20"
								:style="{color: starIndex < 3 ? '#FF4040' : '#FFD2D2'}"></view>
						</view>
					</view>
				</view>
				<view class="comment-txt font28">入住华望城已经有一段时间了，越来越喜欢这里的氛围！清晨被鸟鸣叫醒，傍晚在花园散步遇到热情的邻居，还能看到孩子们在游乐区欢声笑语</view>
				<view class="flex start comment-image">
					<image v-for="imageIndex in 5" :src="IMAGE_URL + '/static/login/bg.png'"></image>
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	import headerVue from '@/components/header.vue'
	import {
		searchApi
	} from '../../api/modules/shop'
	import appConfig from '@/config/app.js'

	export default {
		data() {
			return {
				IMAGE_URL: appConfig.IMAGE_URL,
				params: {
					keyword: ''
				},
				type: 0,
				typeList: [{
						name: '全部',
						num: 0
					},
					{
						name: '好评',
						num: 0
					},
					{
						name: '中评',
						num: 0
					},
					{
						name: '差评',
						num: 0
					},
				]
			}
		},
		components: {
			headerVue
		},
		mounted() {},
		methods: {
			searchInput() {
				console.log(11)
				searchApi(this.params)
			}
		}
	}
</script>
<style lang="scss" scoped>
	.main {
		background: #F6F6F6;
		height: 100vh;
	}

	.scroll-x {
		height: 88rpx;
		margin: 28rpx 32rpx 0 !important;
		box-sizing: border-box;
		width: auto;
		padding: 0 !important;
		
		.item {
			margin-left: 40rpx;
			flex-shrink: 0;
		}
		
		.item:nth-child(1) {
			margin-left: 28rpx;
		}
	}

	.list {
		padding: 28rpx 32rpx;
		box-sizing: border-box;
	}

	.search-box {
		height: 64rpx;
		background: #EFF9FF;
		border-radius: 60rpx;
		padding: 0 28rpx;
		width: 100%;
		box-sizing: border-box;
		position: relative;
		left: -10rpx;

		.iconfont {
			color: $uni-text-color-grey;
			margin-right: 20rpx;
		}

		.input {
			width: 100%;
			height: 100%;
			color: $uni-text-color-grey;
			font-size: 28rpx;
		}
	}

	.white-box {
		background: $uni-bg-color;
		box-shadow: 0rpx 4rpx 20rpx 0rpx rgba(0, 0, 0, 0.1);
		border-radius: 20rpx;
		box-sizing: border-box;
		padding: 28rpx;
		margin-bottom: 28rpx;

		.user-info {
			.avatar {
				width: 96rpx;
				height: 96rpx;
				border-radius: 50%;
				flex-shrink: 0;
				margin-right: 20rpx;
			}

			.user-name {
				margin-bottom: 12rpx;
			}

			.time {
				color: $uni-text-color-grey;
			}

			.icon-starFull {
				margin-right: 8rpx;
				width: 20rpx;
			}
		}

		.comment-txt {
			margin-top: 28rpx;
		}

		.comment-image {
			flex-wrap: wrap;

			image {
				width: calc((100% - 44rpx) / 3);
				height: 220rpx;
				border-radius: 16rpx;
				margin-right: 22rpx;
				margin-top: 28rpx;

				&:nth-child(3n) {
					margin-right: 0;
				}
			}
		}
	}
</style>